//生成随机4位数验证码
export const getCode = () => {
  return Math.random().toString(16).slice(-4);
};

//从请求头中获取token
export const extractTokenFromHeader = (request: any): string | undefined => {
  const [type, token] = request.headers.authorization?.split(' ') ?? [];
  return type === 'Bearer' ? token : undefined;
};